package com.bw.contorller;

import com.bw.entity.User;
import com.bw.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserContorller {
    @Autowired
    UserService userService;

    @RequestMapping("login")
    public String toLogin(User user, Model model, HttpSession session){
        User user1=userService.login(user);
        if(user1!=null){
            session.setAttribute("user",user1);
            return "redirect:list";
        }
        return "login";
    }

}
